import { Component, OnInit } from '@angular/core';
import {DataService} from "../data_service";
import {ActivatedRoute, Router} from "@angular/router";

@Component({
  selector: 'app-updatebook',
  templateUrl: './updatebook.component.html',
  styleUrls: ['./updatebook.component.css']
})
export class UpdatebookComponent implements OnInit {
  title="Update Book"
  public  book: any = {}
  categorys: any = []


  constructor(public service: DataService,public router:Router,public route:ActivatedRoute) {
  }

  ngOnInit(): void {
    this.book={...this.route.snapshot.queryParams}
    this.service.getCategorys().subscribe((resp:any)=>{
      this.categorys=resp
    })
  }

  update() {
    console.log(this.book)
    this.service.putData(this.book).subscribe(_=>{
      this.router.navigate(['/admin'])
    })

  }
}
